#include "print.h"

#include "huks/native_huks_api.h"
#include "huks/native_huks_param.h"

enum {
    FAIL = -1,
    OK = 0,
};

#define LOG_OPERATION_HUKS_RESULT(op) LOGE("%40s: %d", #op, (op).errorCode)

int main()
{
    LOGE("Hello main");
    int ret = 0;
    int userId = 2333;
    struct OH_Huks_Blob keyAlias = {};
    struct OH_Huks_Blob handle = {};
    struct OH_Huks_ParamSet paramSet = {};
    struct OH_Huks_ParamSet paramSetOut = {};
    struct OH_Huks_Blob key = {};
    struct OH_Huks_Blob wrappingKeyAlias = {};
    struct OH_Huks_CertChain certChain = {};
    struct OH_Huks_Blob token = {};
    LOG_OPERATION_HUKS_RESULT(OH_Huks_GenerateKeyItemAsUser(userId, &keyAlias, &paramSet, &paramSetOut));
    LOG_OPERATION_HUKS_RESULT(OH_Huks_ImportKeyItemAsUser(userId, &keyAlias, &paramSet, &key));
    LOG_OPERATION_HUKS_RESULT(OH_Huks_ImportWrappedKeyItemAsUser(userId, &keyAlias, &wrappingKeyAlias, &paramSet, &key));
    LOG_OPERATION_HUKS_RESULT(OH_Huks_ExportPublicKeyItemAsUser(userId, &keyAlias, &paramSet, &key));
    LOG_OPERATION_HUKS_RESULT(OH_Huks_DeleteKeyItemAsUser(userId, &keyAlias, &paramSet));
    LOG_OPERATION_HUKS_RESULT(OH_Huks_GetKeyItemParamSetAsUser(userId, &keyAlias, &paramSet, &paramSetOut));
    LOG_OPERATION_HUKS_RESULT(OH_Huks_IsKeyItemExistAsUser(userId, &keyAlias, &paramSet));
    LOG_OPERATION_HUKS_RESULT(OH_Huks_AttestKeyItemAsUser(userId, &keyAlias, &paramSet, &certChain));
    LOG_OPERATION_HUKS_RESULT(OH_Huks_AnonAttestKeyItemAsUser(userId, &keyAlias, &paramSet, &certChain));
    LOG_OPERATION_HUKS_RESULT(OH_Huks_InitSessionAsUser(userId, &keyAlias, &paramSet, &handle, &token));
    LOGE("Hello main ret = %d", ret);
	return OK;
}